package com.ruoyi.property.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.property.domain.StaffFeeManageInfo;
import com.ruoyi.property.service.IStaffFeeManageInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工收费Controller
 * 
 * @author sux
 * @date 2021-06-30
 */
@Controller
@RequestMapping("/property/staffFeeManageInfo")
public class StaffFeeManageInfoController extends BaseController
{
    private String prefix = "property/staffFeeManageInfo";

    @Autowired
    private IStaffFeeManageInfoService staffFeeManageInfoService;

    @RequiresPermissions("property:staffFeeManageInfo:view")
    @GetMapping()
    public String staffFeeManageInfo()
    {
        return prefix + "/staffFeeManageInfo";
    }

    /**
     * 查询员工收费列表
     */
    @RequiresPermissions("property:staffFeeManageInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StaffFeeManageInfo staffFeeManageInfo)
    {
        startPage();
        List<StaffFeeManageInfo> list = staffFeeManageInfoService.selectStaffFeeManageInfoList(staffFeeManageInfo);
        return getDataTable(list);
    }

    /**
     * 导出员工收费列表
     */
    @RequiresPermissions("property:staffFeeManageInfo:export")
    @Log(title = "员工收费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StaffFeeManageInfo staffFeeManageInfo)
    {
        List<StaffFeeManageInfo> list = staffFeeManageInfoService.selectStaffFeeManageInfoList(staffFeeManageInfo);
        ExcelUtil<StaffFeeManageInfo> util = new ExcelUtil<StaffFeeManageInfo>(StaffFeeManageInfo.class);
        return util.exportExcel(list, "staffFeeManageInfo");
    }

    /**
     * 新增员工收费
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存员工收费
     */
    @RequiresPermissions("property:staffFeeManageInfo:add")
    @Log(title = "员工收费", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StaffFeeManageInfo staffFeeManageInfo)
    {
        return toAjax(staffFeeManageInfoService.insertStaffFeeManageInfo(staffFeeManageInfo));
    }

    /**
     * 修改员工收费
     */
    @GetMapping("/edit/{staffFeeId}")
    public String edit(@PathVariable("staffFeeId") Long staffFeeId, ModelMap mmap)
    {
        StaffFeeManageInfo staffFeeManageInfo = staffFeeManageInfoService.selectStaffFeeManageInfoById(staffFeeId);
        mmap.put("staffFeeManageInfo", staffFeeManageInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存员工收费
     */
    @RequiresPermissions("property:staffFeeManageInfo:edit")
    @Log(title = "员工收费", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StaffFeeManageInfo staffFeeManageInfo)
    {
        return toAjax(staffFeeManageInfoService.updateStaffFeeManageInfo(staffFeeManageInfo));
    }

    /**
     * 删除员工收费
     */
    @RequiresPermissions("property:staffFeeManageInfo:remove")
    @Log(title = "员工收费", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(staffFeeManageInfoService.deleteStaffFeeManageInfoByIds(ids));
    }
}
